#include <cstdio>
#include <algorithm>

using namespace std;

struct Node
{
    long long x, y;
    int id;
};

bool cmp1( const Node &a, const Node &b )
{
    return a.x < b.x;
}

bool cmp2( const Node &a, const Node &b )
{
    return a.y < b.y;
}

Node a[ 100001 ];
long long x[ 100001 ], y[ 100001 ];

int mabs( int a ) { return ( a < 0 )? -a: a; }

int main( )
{
    int n, t, i;
    long long ans, s, s2, xx, yy;
    scanf("%d", &t);
    while ( t-- )
    {
        scanf("%d", &n);
        for ( i = 0; i < n; i++ )
        {
            a[ i ].id = i;
            scanf("%I64d%I64d", &a[ i ].x, &a[ i ].y);
            xx = a[ i ].x;
            yy = a[ i ].y;
            a[ i ].x = xx + yy;
            a[ i ].y = yy - xx;
        }
        sort( a, a + n, cmp1 );
        s2 = s = 0;
        for ( i = 0; i < n; i++ )
            s += a[ i ].x - a[ 0 ].x;
        x[ a[ 0 ].id ] = s;
        for ( i = 1; i < n; i++ )
        {
            s2 += i * ( a[ i ].x - a[ i - 1 ].x );
            s -= ( n - i ) * ( a[ i ].x - a[ i - 1 ].x );
            x[ a[ i ].id ] = s + s2;
        }
        sort( a, a + n, cmp2 );
        s2 = s = 0;
        for ( i = 0; i < n; i++ )
            s += a[ i ].y - a[ 0 ].y;
        y[ a[ 0 ].id ] = s;
        for ( i = 1; i < n; i++ )
        {
            s2 += i * ( a[ i ].y - a[ i - 1 ].y );
            s -= ( n - i ) * ( a[ i ].y - a[ i - 1 ].y );
            y[ a[ i ].id ] = s + s2;
        }
        ans = x[ 0 ] + y[ 0 ];
        for ( i = 1; i < n; i++ )
            if ( ans > x[ i ] + y[ i ] )
                ans = x[ i ] + y[ i ];
        printf("%I64d\n", ans / 2);
    }
    return 0;
}
